package prefuse.tp.svn;

import prefuse.action.assignment.DataColorAction;
import prefuse.data.Node;
import prefuse.util.ColorLib;
import prefuse.visual.VisualItem;

public class GraphRadial_dataColorAction extends DataColorAction {

	public GraphRadial_dataColorAction(String group, String dataField,
			int dataType, String colorField, int[] palette) {
		super(group, dataField, dataType, colorField, palette);
	}
	
    public int getColor(VisualItem item) {
    	if(item.getSourceTuple() instanceof Node){
    		Node n = ((Node)(item.getSourceTuple()));
    		if(n.getInt("type")==GraphRadial_Affectations.ETUDIANT){

		        float i = modulo(n.hashCode(), 30)/30f;
	        	return ColorLib.hsb(i, .2f, .9f);
    		}
		}
    	return super.getColor(item);
    }

    int modulo(int n, int m) {
    	int d = n/m;
    	return n-d*m;
    }
}
